/**
* @Author: Crissu
* @Date: 2021/3/24 16:13
# @About: 简单工厂
*/

package __factory

import "fmt"

type IRuleConfigParser interface {
	Parse(data []byte)
}

// jsonRuleConfigParser jsonRuleConfigParser
type jsonRuleConfigParser struct {
}

// Parse Parse
func (J jsonRuleConfigParser) Parse(data []byte) {
	panic("implement me")
}

// yamlRuleConfigParser yamlRuleConfigParser
type yamlRuleConfigParser struct {
}

// Parse Parse
func (Y yamlRuleConfigParser) Parse(data []byte) {
	panic("implement me")
}

func NewIRuleConfigParser(t string) IRuleConfigParser {
	switch t {
	case "json":
		return jsonRuleConfigParser{}
	case "yaml":
		return yamlRuleConfigParser{}
	}
	return nil
}

/**
excise
*/
type IGetUserInfo interface {
	getUserInfo()
}

type first struct {
	name string
	age  int
}

type second struct {
	first
	tag string
}

func (s second) getUserInfo() {
	fmt.Println(s.name, s.age, s.tag)
}

type third struct {
	first
	pic string
}

func (t third) getUserInfo() {
	fmt.Println(t.name, t.age, t.pic)
}

func NewFactory(se string, ff first) IGetUserInfo {
	switch se {
	case "second":
		return second{
			first: ff,
			tag:   "tag",
		}
	case "third":
		return third{
			first: ff,
			pic:   "pic",
		}
	}
	return nil
}
